//如果当前的深度等于ret的个数证明还没遍历到此层

class Solution {
public:
        vector<int> ret;

    vector<int> rightSideView(TreeNode* root) {
        dfs(root,0);

        return ret;
    }
    void dfs(TreeNode* node ,int depth)
    {
        if(node==nullptr) return;
        if(depth==ret.size()) ret.push_back(node->val);

        dfs(node->right,depth+1);
        dfs(node->left,depth+1);
    }
};